package service

import (
	"gitee.com/Luna-CY/Golang-Project-Template/internal/context"
	"gitee.com/Luna-CY/Golang-Project-Template/internal/errors"
	"gitee.com/Luna-CY/Golang-Project-Template/internal/interface/dao"
	"gitee.com/Luna-CY/Golang-Project-Template/model"
)

type BusinessExample interface {
	Transactional

	// CreateExample 创建 example
	// 必填字段通过接口签名强制传入，可选字段通过 fields 传入
	CreateExample(ctx context.Context, name string, value uint64, fields ...BusinessExampleField) (*model.BusinessExample, errors.Error)

	// UpdateExample 更新 example
	UpdateExample(ctx context.Context, example *model.BusinessExample, fields ...BusinessExampleField) errors.Error

	// GetExampleByCondition 从 db 获取 example 通过条件
	// 如果 example 不存在，返回 errors.ErrorRecordNotFound 错误
	GetExampleByCondition(ctx context.Context, options ...dao.BusinessExampleOption) (*model.BusinessExample, errors.Error)

	// ListExampleByCondition 通过简单条件从 db 获取 example
	// 如果 field4 为 nil，则不在此查询中过滤此字段
	ListExampleByCondition(ctx context.Context, page int, size int, options ...dao.BusinessExampleOption) (int64, []*model.BusinessExample, errors.Error)
}
